package com.jeeplus.modules.guide.web;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.modules.guide.service.WXService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags="高新服务接口")
@RestController
@RequestMapping("/wx")
@RequiredArgsConstructor
public class WXController {
    private static final Logger log = LoggerFactory.getLogger(WXController.class);
    private final WXService wxService;

    /**
     * 电话直通
     *
     * @return
     */
    @GetMapping(value ="mobileListByWX")
    public AjaxJson mobileListByWX(){
        return AjaxJson.success().put("data",wxService.mobileListByWX());
    }

    /**
     * 排队数据 历史数据统计分析集成
     *
     * @return
     */
    @GetMapping(value ="queueHistory")
    public AjaxJson queueHistory(){
        List <String> table = wxService.findTable();
        if(table.size() >= 1){
            for(String str : table){
                //统计年月份数据
                if(wxService.inserTableTimeValue(str) <= 0){
                    return AjaxJson.error("历史统计失败");
                }
            }
        }
        return AjaxJson.success("历史统计完成！");
    }
}
